<?php

declare(strict_types=1);

namespace App\Model\Ocpc;

use Hyperf\DbConnection\Model\Model;

/**
 *  OcpcBaiduLoseLog
 */
class OcpcBaiduLoseLog extends Model
{
    protected $table = 'ocpc_baidu_lose_log';

    static function shift($channel)
    {
        $res = self::where('channel', $channel)->where('status',0)->orderBy('id','desc')->first();
        if ($res) {
            self::where('id', $res['id'])->update(['status'=>1]);
            return [
                'id' => $res['ocpc_id'],
                'channel' => $res['channel'],
                'callback_url' => $res['callback_url'],
                'akeys' => $res['akeys']
            ];
        }
        return [];
    }
}